//货柜管理-型号列表
App.util.ns('Admin.Cabinet.Type');
App.pages.add((function(){
    var NS = Admin.Cabinet.Type;
    var page = new App.Page({
        name: 'cabinet/type/index'
    });
    //页面初始化
    page.initStack.add('dataTable', function(){
        //面包屑导航
        this.setBreadcrumb([{
            icon: '<i class="fa fa-window-restore"></i>',
            content: '货柜管理'
        }, {
            content: '型号管理'
        }]);
        this.dataTable = new App.DataTable({
            baseUrl: '/admin/cabinet/type',
            dataUrl: 'lists',
            table: {
                id: 'id',
                main: 0,
                columns: App.util.copy(NS.Conf.columns)
            },
            filter: [
                {type: 'keywords'},
                {type: 'timeRange'},
                {type: 'select', name: 'status', title: '状态', width: '120px', items: [
                    [0, '下线'],
                    [1, '在线']
                ]},
                {type: 'select', name: 'factory_id', title: '生产厂商', width: '120px',
                    items: App.models.get('factories-all'),
                    item_key: 'id',
                    item_name: 'name'
                }
            ],
            menu: [
                {parent: 'add', permission: 'op:admin.cabinet.cabinetType.create'},
                {parent: 'view', permission: 'op:admin.cabinet.cabinetType.detail'},
                {parent: 'edit', permission: 'op:admin.cabinet.cabinetType.update'},
                {parent: 'drop', permission: 'op:admin.cabinet.cabinetType.delete'},
                {type: 'inline', permission: 'op:admin.cabinet.cabinetType.online', name: '上线', operation: {type: 'change', url: 'online'}, conditions: [['status', '0']]},
                {type: 'inline', permission: 'op:admin.cabinet.cabinetType.offline', name: '下线', operation: {type: 'change', url: 'offline'}, conditions: [['status', '1']]},
                {type: 'multi', name: '状态', openable: true, items: [
                    {type: 'multi', permission: 'op:admin.cabinet.cabinetStore.multiOnline', name: '上线', operation: {type: 'change', url: 'multiOnline', confirm: true}},
                    {type: 'multi', permission: 'op:admin.cabinet.cabinetStore.multiOffline', name: '下线', operation: {type: 'change', url: 'multiOffline', confirm: true}}
                ], permission:[
                    'op:admin.cabinet.cabinetType.multiOnline',
                    'op:admin.cabinet.cabinetType.multiOffline'
                ]},
                {parent: 'multiDrop', permission: 'op:admin.cabinet.cabinetType.multiDelete'},
                {parent: 'oplog', permission: 'op:admin.cabinet.cabinetType.getOpLogs'}
            ],
            detail: {
                form: {
                    items: App.util.copy(NS.Conf.form)
                }
            }
        }, page);
        this.dataTable.fix(this.contentContainer);
        this.dataTable.loadData();
    });
    //页面刷新
    page.refreshStack.add('dataTable', function(){
        this.dataTable.loadData(true);
    });
    //页面销毁
    page.destroyStack.add('dataTable', function(){
        this.dataTable.destroy();
    });
    return page;
})());